package view.elements{
	/**
	 * @author Alejandro
	 */
	
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.display.Shape;
	import flash.events.MouseEvent;
	import view.components.buttons.CompleteButton;
	import view.concret.MoveBall;
	import view.elements.ConcretApplication;
	import view.components.text.CompleteText;
	
	public class AppContainerTemplate01 extends Sprite {
		
		private var play:Boolean;
		private var application:ConcretApplication;
		private var playButton:CompleteButton;
		private var stopButton:CompleteButton;
		
		public function AppContainerTemplate01(){
			init();
		}
		
		private function init(e:Event = null):void{
			play = true;	
			createButtons();			
			application = new MoveBall();
			addChild(application);
			
			var style:Object = {
				x:"100",
				y:"400",
				backgroundColor:"AA0099",
				text:"hola",
				height:"100",
				size: "44"
				};
			var text:CompleteText = new CompleteText(style);
		    addChild(text);
		}
			
		private function createButtons():void{
			createPlayButton();
			createStopButton();
		}
		
		
		private function createPlayButton():void{
			var style:Object = {
				width: 100,
				height: 50,
				x:"0",
				y:"550",
				upColor:"AA0099",
				text:"jodido"
				};
			playButton = new CompleteButton(style);			
			playButton.addEventListener(MouseEvent.CLICK, playApplication);			
			addChild(playButton);
		}
		
		private function createStopButton():void{
			var style:Object = {
				text:"input",
				width: 100,
				height: 50,
				x:"100",
				y:"550",
				upColor:"AAAAAA",
				visible:"false"
				};
			stopButton = new CompleteButton(style);			
			stopButton.addEventListener(MouseEvent.CLICK, stopApplication);
			addChild(stopButton);
		}		
		
		private function playApplication(event:MouseEvent):void {
			this.application.playApplication();
			stopButton.visible = true;
			playButton.visible = false;
		}
		
		private function stopApplication(event:MouseEvent):void {
			this.application.stopApplication();
			stopButton.visible = false;
			playButton.visible = true;
		}
	}
}